package com.medicine.hbp.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.medicine.hbp.R;

public class TopView extends LinearLayout {
	/**
	 * 头部左侧按钮
	 */
	public ImageView btn_image_left;
	/**
	 * 头部右侧按钮
	 */
	public ImageView btn_image_right;
	/**
	 * 头部左侧返回按钮
	 */
	public ImageView btn_image_left_exit;
	/**
	 * 头部文字
	 */
	public TextView text_title;
	/**
	 * 头部右侧文字
	 */
	public TextView text_title_right;
	private View view;

	public TopView(Context context) {
		super(context);
		initView(context);
	}

	public TopView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initView(context);
	}

	public TopView(Context context, AttributeSet attrs, int defStyleAttr) {
		super(context, attrs, defStyleAttr);
		initView(context);
	}

	private void initView(Context context) {
		// LinearLayout.LayoutParams lp = new
		// LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
		// LayoutParams.WRAP_CONTENT);
		view = LayoutInflater.from(context).inflate(R.layout.top, this);

		btn_image_left = (ImageView) findViewById(R.id.btn_image_left);
		btn_image_right = (ImageView) findViewById(R.id.btn_image_right);
		btn_image_left_exit= (ImageView) findViewById(R.id.btn_image_left_exit);
		text_title = (TextView) findViewById(R.id.text_title);
		text_title_right = (TextView) findViewById(R.id.text_title_right);
		// addView(view, lp);
	}

	public ImageView getLeftImageView() {
		return btn_image_left;
	}

	/**
	 * 头部文字更改
	 */
	public void setTitle(String title) {
		text_title.setText(title);
	}
	/**
	 * 头部文字颜色更改
	 */
	public void setTitleColor(int colors) {
		text_title.setTextColor(colors);
	}
	/**
	 * 头部右侧文字更改
	 */
	public void setRightTitle(String title) {
		text_title_right.setText(title);
	}
	/**
	 * 头部右侧文字更改
	 */
	public void setRightTitleColor(int colors) {
		text_title_right.setTextColor(colors);
	}
	/**
	 * 头部右侧点击事件
	 */
	public void setTextRightOnClick(OnClickListener onClickListener) {
		text_title_right.setOnClickListener(onClickListener);
	}
	/**
	 * 头部右侧文字显示与否
	 */
	public void setRightTxtVisibility(int visibility) {
		text_title_right.setVisibility(visibility);
	}

	/**
	 * 头部左侧点击事件
	 */
	public void setLeftOnClick(OnClickListener onClickListener) {
		btn_image_left.setOnClickListener(onClickListener);
	}

	/**
	 * 头部左侧返回按钮点击事件
	 */
	public void setLeftOnClickExit(OnClickListener onClickListener) {
		btn_image_left_exit.setOnClickListener(onClickListener);
	}

	/**
	 * 头部左侧返回按钮点击事件
	 */
	public void setLeftImageResource(int resId) {
		btn_image_left_exit.setImageResource(resId);
	}
	/**
	 * 头部右侧点击事件
	 */
	public void setRightOnClick(OnClickListener onClickListener) {
		btn_image_right.setOnClickListener(onClickListener);
	}
	/**
	 * 头部右侧按钮图片切换
	 */
	public void setRightImageResource(int resId) {
		btn_image_right.setImageResource(resId);
	}
	/**
	 * 头部右侧按钮图片切换
	 */
	public void setRightImagePadding(int left,int top,int right,int bottom) {
		btn_image_right.setPadding(left, top, right, bottom);
	}
	/**
	 * 头部右侧显示与否
	 */
	public void setRightVisibility(int visibility) {
		btn_image_right.setVisibility(visibility);
	}

	/**
	 * 头部左侧显示与否
	 */
	public void setLeftVisibility(int visibility) {
		btn_image_left.setVisibility(visibility);
	}

	/**
	 * 头部左侧返回按钮显示与否
	 */
	public void setLeftVisibilityExit(int visibility) {
		btn_image_left_exit.setVisibility(visibility);
	}
}
